#include <allegro.h>
//#include "lib/CSprite.h"
#include "CHuman.h"

#define WIN_W 640
#define WIN_H 480

void init();
void deinit();

int main() {
	init();
	BITMAP *buffer;
	buffer = create_bitmap(WIN_W, WIN_H);
	ASSERT(*buffer != NULL);

	CHuman hero;
    hero.LoadBitmap("res_img/MikotoYoroi.bmp");
    hero.SetTransBitmap(74, 123, 90);
    hero.SetStay(14, 11, 35, 59);
    hero.SetWalk(80, 15, 50, 70, 4);
	
	while (!key[KEY_ESC]) {
		/* put your code here */	
		//hero.Blit(buffer, 0, 0, 0, 0);
		//hero.BlitSprite(buffer, 0, 0, 0, 0, 100, 100);
		//hero.Blit(buffer, 0, 0, 0, 0, 100, 100);
		hero.BlitStay(buffer, 10, 10);
		hero.BlitWalk(buffer, 100, 10);
		
		blit(buffer, screen, 0, 0, 0, 0, WIN_W, WIN_H);
		clear_bitmap(buffer);
	}

	deinit();
	return 0;
}
END_OF_MAIN()

void init() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_mouse();
	/* add other initializations here */
}

void deinit() {
	clear_keybuf();
	/* add other deinitializations here */
}
